﻿using System;
using System.Web.UI;
using WorkOrder.Model;
using WorkOrder.Business;

namespace WorkOrder
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            txtUserID.Focus();
        }

        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            Model_Table_User user_modle = new Business_Table_User().Login(Server.HtmlEncode(txtUserID.Text.Trim()), Server.HtmlEncode(txtPassword.Text.Trim()));
            if (user_modle != null)
            {
                Session.Add("UserID", user_modle.User_id);
                Session.Add("UserName", user_modle.Remark);
                Session.Add("UserLoginID", user_modle.User_name);
                Response.Redirect("index.htm");
            }
            else
            {
                Session.Clear();
                ClientScript.RegisterClientScriptBlock(this.GetType(), "windowhref", "<script type='text/javascript'>alert('用户名或密码错误，请重新登录！');</script>");
            }
        }
    }
}
